/* eslint-disable no-new */
Vue.use(window.antd.default)
// Vue.use(window['vue-ele-form'])

new Vue({
  el: '#form',
  data() {
    return {
      formData: {
        name: '张三2',
        age: 18,
      },
      formDesc: {
        name: {
          type: 'input',
          label: '姓名2',
          value: '张三',
        },
        age: {
          type: 'input',
          label: '年龄2',
          value: 18,
        },
      },
    }
  },
  template: `
    <div>
      <ele-form
        v-model="formData"
        :form-desc="formDesc"
        labelWidth="100px"
        @requestFn="handleSubmit"
      ></ele-form>
    </div>
  `,
  methods: {
    handleSubmit() {
      fetch('/api/hello', {
        headers: {
          'content-type': 'application/json',
        },
        body: JSON.stringify(this.formData),
        method: 'POST',
        credentials: 'include',
      })
        .then(response => response.json())
        .then(result => {
          console.log(result)
        })
        .catch(error => {
          console.log('error', error)
        })
    },
  },
})
